package com.zzw.model;

import org.apache.commons.lang3.StringUtils;

/**
 * @author zzw
 * @version 1.0
 * @title StuSexEnum
 * @description <p>性别枚举类</p>
 * @datetime 2022-12-28 8:19 下午
 */
public enum StuSexEnum {

    N("N", "未知"),
    M("M", "男"),
    F("F", "女"),
    ;

    /**
     * 编码
     */
    private final String code;
    /**
     * 描述
     */
    private final String desc;

    StuSexEnum(String code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public static boolean hasStuCode(String code){
        return findByCode(code) != null;
    }

    public static StuSexEnum findByCode(String code){
        if(StringUtils.isEmpty(code)){
            return null;
        }
        for(StuSexEnum sexEnum: StuSexEnum.values()){
            if(sexEnum.getCode().equals(code)){
                return sexEnum;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
